package com.ssy.lingxi.member.merchant.repository;

import com.ssy.lingxi.member.merchant.entity.MemberOrderCommentDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 会员订单评价Repository
 * @author yzc
 * @version 2.0.0
 * @date 2021/8/3
 */
@Repository
public interface MemberOrderCommentRepository extends JpaRepository<MemberOrderCommentDO, Long>, JpaSpecificationExecutor<MemberOrderCommentDO> {

    List<MemberOrderCommentDO> findAllByBuyerCompleteCommentStatus(Integer completeCommentStatus);

    List<MemberOrderCommentDO> findAllByVendorCompleteCommentStatus(Integer completeCommentStatus);

    @Modifying
    @Query("UPDATE MemberOrderCommentDO oc set oc.buyerCompleteCommentStatus = :status where oc.id = :id")
    int updateBuyerCompleteCommentStatus(@Param("status") Integer status, @Param("id") Long id);

    @Modifying
    @Query("UPDATE MemberOrderCommentDO oc set oc.vendorCompleteCommentStatus = :status where oc.id = :id")
    int updateVendorCompleteCommentStatus(@Param("status") Integer status, @Param("id") Long id);
}
